'use strict';


/**
 * @description 企业/个人详情接口
 * @param {Object}  ctx 函数的执行上下文
 * @param {Object}  args 前端传递过来的参数
 */
const db = uniCloud.database();
const { SuccessModel, ErrorModel } = require('status-modal');

exports.main = async (args, ctx) => {
	const { id, type } = args;
	const user = db.collection('user');
	const company = db.collection('company');
	const collection = await (type == 'man' ? user : company).where({
		_id: id,
	}).get();
	const arr = collection.data;
	if (arr.length) {
		let data = arr[0];
		delete data.appId;
		delete data.appKey;
		return new SuccessModel('获取成功', data);
	} else return new ErrorModel('获取失败');
};
